<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!doctype html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="renderer" content="webkit">
    <title>实名认证审核</title>
    <link rel="icon" href="favicon.ico" type="image/x-icon"/>
    <!-- 当前页面样式 -->
    <link rel="stylesheet" href=<s:url value="/css/common.css"/>>
	<script type="text/javascript" src="<s:url value="/js/jquery-1.9.1.js" />"></script>
	<script type="text/javascript" src="<s:url value="/js/jquery.validate.min.js" />"></script>
	<script type="text/javascript" src="<s:url value="/js/pwms.validate.js" />"></script>
	<script type="text/javascript" src="<s:url value="/js/My97DatePicker/WdatePicker.js"/>"></script>
	<script type='text/javascript' src='<s:url value="/js/YLlightbox.js"/>'></script>
	<script type='text/javascript' src='<s:url value="/js/pageAjax.js"/>'></script>
	<script type='text/javascript' src='<s:url value="/js/checkMerinfoinfoCount.js"/>'></script>
	<style>
		 .fieldError { color: red; text-align: left; }
		.error { float: none; color: red;  vertical-align: top;font-size: 11px;}
		#YLimgwrap {
		  position: fixed;
		  left: 0;
		  top: 0;
		  right: 0;
		  bottom: 0;
		  background: rgba(0, 0, 0, 0);
		  z-index: 10;
		  display: none;
		}
	</style>
</head>
<body>

<s:form id="operatorAuthForm" method="POST" onsubmit="return checkForm();" action="/operatorAuthCheck/checkReceive.ct" theme="simple">

<s:hidden id="receiveId" name="receiveId" value="%{#request.operatorAuth.receiveId}"/>

<table class="tb" style="width:100%">
    <tbody>
        <tr class="tb-line">
            <td class="tb-td" colspan="4" ><div class="tb-h3">实名信息审核</div></td>
        </tr>
        <tr class="tb-line">
            <td align="right" class="tb-td" style="width:110px;">
                <div class="tb-h4">账户：</div>
            </td>
            <td class="tb-td" >
             	<label class="tb-input-lengthen">
             	<s:property value="#request.operatorAuth.accountNo"/>
             	<s:if test="#request.operatorAuth.phoneReason != null">
             		<font color="red">
             			（该手机号为黑名单）
             		</font>
             	</s:if>
             	<s:else>
             		<font color="red">
             			（正常）
             		</font>
             	</s:else>
                </label>
            </td>
            <td align="right" class="tb-td" style="width:110px;">
                <div class="tb-h4">真实姓名：</div>
            </td>
            <td class="tb-td" >
             	<label class="tb-input-lengthen">
             	<s:property value="#request.operatorAuth.userName"/>
             	<s:hidden id="realName" name="realName" value="%{#request.operatorAuth.userName}"/>
				</label>
            </td>
        </tr>

        <tr class="tb-line">
            <td align="right" class="tb-td">
                <div class="tb-h4">证件类型：</div>
            </td>
            <td class="tb-td" >
                <label class="tb-input-lengthen">
                <s:property value="%{#request.operatorAuth.cardType =='01'?'身份证':'其他'}"/> 
				</label>
            </td>
            <td align="right" class="tb-td">
                <div class="tb-h4">证件号码：</div>
            </td>
            <td class="tb-td">
                <label class="tb-input-lengthen">
                <s:property value="#request.operatorAuth.cardNo"/>
                <s:hidden id="idCard" name="idCard" value="%{#request.operatorAuth.cardNo}"/>
                <s:if test="#request.operatorAuth.idCardReason != null">
             		<font color="red">
             			（该身份证号为黑名单）
             		</font>
             	</s:if>
             	<s:else>
             		<font color="red">
             			（正常）
             		</font>
             	</s:else>
				</label>
            </td>
        </tr>
        <tr class="tb-line">
            <td align="right" class="tb-td">
                <div class="tb-h4">驳回次数：</div>
            </td>
            <td class="tb-td" >
                <label class="tb-input-lengthen">
                <s:if test="#request.operatorAuth.authReasonList != null">
                	<s:property value="#request.operatorAuth.authReasonList.size()"/>
                </s:if>
                <s:else>
                	0
                </s:else>
				</label>
            </td>
            <td align="right" class="tb-td">
                <div class="tb-h4">驳回原因</div>
            </td>
            <td class="tb-td" >
                <s:if test="#request.operatorAuth.authReasonList != null">
                <s:iterator value="#request.operatorAuth.authReasonList" var="authReasonList">
                	<s:iterator value="authReasonList" var="authReason">
                		<s:property value="authReason"/>
                	</s:iterator>
                	<br>
                </s:iterator>
                </s:if>
            </td>
        </tr>
        <tr class="tb-line">
            <td align="right" class="tb-td">
                <div class="tb-h4">身份证验证：</div>
            </td>
            <td class="tb-td" style="text-align: center;">
                <input style="width: 40px;height: 30px" id="yzBtn" type="button" value="验证" onclick="yzIdCard()"/> 
            </td>
            <td align="right" class="tb-td">
                <div class="tb-h4">身份证有效日期</div>
            </td>
            <td class="tb-td">
               	<input id="startDate"  value="<s:property value="#request.operatorAuth.ext1"/>">
            	<img style="margin-left:-20px" onClick="WdatePicker({el:'startDate',dateFmt:'yyyyMMdd'})"  src="<s:url value="/js/My97DatePicker/skin/datePicker.gif" />" width="16" height="22" /> --
               	<span id="valueHtml">
               		<s:if test="#request.operatorAuth.ext2=='长期'">
	               		<input type="hidden" value="0" id="isForLong">
	               		<input id="endDate" disabled="disabled" value="<s:property value="#request.operatorAuth.ext2"/>">
	               		<img style="margin-left:-20px" onClick="WdatePicker({el:'endDate',dateFmt:'yyyyMMdd'})"  src="<s:url value="/js/My97DatePicker/skin/datePicker.gif" />" width="16" height="22" />
	               	</s:if>
	               	<s:else>
	               		<input type="hidden" value="1" id="isForLong">
	               		<input id="endDate" value="<s:property value="#request.operatorAuth.ext2"/>">
	               		<img style="margin-left:-20px" onClick="WdatePicker({el:'endDate',dateFmt:'yyyyMMdd'})"  src="<s:url value="/js/My97DatePicker/skin/datePicker.gif" />" width="16" height="22" />
	               	</s:else>
               	</span> 
               	<input type="button" value='长期有效' id="isForLongButton">
               	<input type="button" value="修改" id="dataUpdateButton">
            </td>
        </tr>
        
        <tr id="trShow" style="display: none">
        	<td colspan="4" id="tdShow" style="text-align: center;">
       	 		
        	</td>
        </tr>
        
        <tr class="tb-line">
        	<td  class="tb-td" colspan="4" style="padding:0;">
        		<table style="width: 100%" class="tb-pic YLlightbox" >
        			<tr class="tb-line">
        				<td class="tb-td" style="padding:5px 0;border:1px solid #e2dfdf;">
        					<label class="pic-uploading">
	        					<a rel="YLlightbox" href="showPhone.ct?accountNo=<s:property value="#request.operatorAuth.accountNo"/>&fileName=<s:property value="#request.operatorAuth.frontImage"/>"  style="display: block;"  >
								         <img   src="showPhone.ct?accountNo=<s:property value="#request.operatorAuth.accountNo"/>&fileName=<s:property value="#request.operatorAuth.frontImage"/>">
								</a>
							</label>
							<div align="center">身份证正面照片</div>
        				</td>
        				<td class="tb-td" style="padding:5px 0;border:1px solid #e2dfdf;">
        					<label class="pic-uploading">
	        					<a rel="YLlightbox" href="showPhone.ct?accountNo=<s:property value="#request.operatorAuth.accountNo"/>&fileName=<s:property value="#request.operatorAuth.revereImage"/>"  style="display: block;" >
								      <img   src="showPhone.ct?accountNo=<s:property value="#request.operatorAuth.accountNo"/>&fileName=<s:property value="#request.operatorAuth.revereImage"/>">
								</a> 
							</label>
							<div align="center">身份证反面照片</div>
        				</td>
        				<td class="tb-td" style="padding:5px 0;border:1px solid #e2dfdf;">
        					<label class="pic-uploading">
	        					<a rel="YLlightbox" href="showPhone.ct?accountNo=<s:property value="#request.operatorAuth.accountNo"/>&fileName=<s:property value="#request.operatorAuth.handleImage"/>"  style="display: block;" >
								      <img   src="showPhone.ct?accountNo=<s:property value="#request.operatorAuth.accountNo"/>&fileName=<s:property value="#request.operatorAuth.handleImage"/>">
								</a> 
							</label>
							<div align="center">手持身份证正面照片</div>
        				</td>
        				<td class="tb-td" style="padding:5px 0;border:1px solid #e2dfdf;">
        					<label class="pic-uploading">
	        					<a rel="YLlightbox" href="showPhone.ct?accountNo=<s:property value="#request.operatorAuth.accountNo"/>&fileName=<s:property value="#request.operatorAuth.handleReverseImage"/>"  style="display: block;" >
								      <img   src="showPhone.ct?accountNo=<s:property value="#request.operatorAuth.accountNo"/>&fileName=<s:property value="#request.operatorAuth.handleReverseImage"/>">
								</a> 
							</label>
							<div align="center">手持身份证反面照片</div>
        				</td>
        			</tr>
        			
        		</table>
        	</td>
        </tr>
             	 
       <tr class="tb-line">
      		  <td   align="right" class="tb-td">
              <div class="tb-h4">审核操作：</div>
             </td>
          <td  align="left" class="tb-td" style="padding-left: 15px;" colspan="3">
          		<s:radio id="" name="status" list="#request.auditingMap" />
          		 <span></span>
          </td>
       </tr>
       <tr class="tb-line" id="resultDetailTr" style="display: none">
      		  <td   align="right" class="tb-td">
              <div class="tb-h4">审核意见：</div>
             </td>
          <td  align="left" class="tb-td" style="padding-left: 15px; " colspan="3">
          		<s:select list="#request.authReasonList" id="resultDetail" name="resultDetail" listKey="name" listValue="name" style="display: none"></s:select>
          		<s:textarea rows="5" cols="100" id="resultTrueDetail" name="resultTrueDetail" cssStyle="width:80%;"  onpropertychange="textCounter(this,100);" oninput="textCounter(this,100);" style="display: none"/>
          		<s:textarea rows="5" cols="100" id="resultLimitDetail" name="resultLimitDetail" cssStyle="width:80%;"  onpropertychange="textCounter(this,100);" oninput="textCounter(this,100);" style="display: none"/>
          </td>
       </tr> 
    </tbody>
</table>
  
    <div align="center" class="line-submit bg-gray">
    		 <input style="width: 40px;height: 30px" id="submitBtn" type="submit" value="提交"/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    		 <input style="width: 40px;height: 30px" id="backBtn" type="button" value="返回"/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    </div>
 	 <a rel="YLlightbox" style="display: none;"  id="lookImg">
        <img />
     </a>
</s:form> 
<script>
	var currentTerNum=1;
    $(function () {
    	//***********************************************************************css
        $('#tabBody').on('click', '.tab-title .tb-title', function () {
            var $this = $(this); /// 点击的对象
            var index = $this.index();  // 点击对象的下标
            // 点击的对象添加active，同类对象移除active
            $this.addClass('active').siblings().removeClass('active');
            // 查找与点击对象相同关系的列表显示并隐藏同类对象
            $('#tabBody').find('.tab-cnt .tb').eq(index).show().siblings().hide();
        });
      //返回
    	$("#goBack").click(function(){
    		 history.go(-1);
    	});
      
    	$("#backBtn").click(function(){
    		window.location.href="<%=basePath%>/operatorAuthCheck/queryOperatorsAuthCheck.ct";
   		});
      
      	$("#isForLongButton").click(function(){
      		if($("#isForLong").val()=="0"){
      			$("#endDate").attr("disabled",false);
      			$("#isForLong").val("1");
      			$("#endDate").val("");
      		}else if($("#isForLong").val()=="1"){
      			$("#endDate").attr("disabled",true);
      			$("#isForLong").val("0");
      			$("#endDate").val("长期");
      		}
      	});
      
		$(":radio").click(function(){
			if($(this).val()=="02"){
				$("#resultLimitDetail").hide();
				$("#resultDetail").show();
				$("#resultTrueDetail").hide();
				$("#resultDetailTr").show();
			}else if($(this).val()=="01"){
				$("#resultLimitDetail").hide();
				$("#resultDetail").hide();
				$("#resultTrueDetail").show();
				$("#resultDetailTr").show();
			}else{
				$("#resultLimitDetail").show();
				$("#resultDetail").hide();
				$("#resultTrueDetail").hide();
				$("#resultDetailTr").show();
			}
		});
      
		$("#YLimgwrap").bind("click",function(e){ 
			var target = $(e.target); 
			if(target.closest("#YLimgcon").length == 0){ 
				$(".YLt_close").trigger("click");
			} 
		}); 
		
		$("#dataUpdateButton").click(function(){
			var endDate = "长期";
			if($("#isForLong").val()=="1"){
				endDate = $("#endDate").val();
			}
			var startDate = $("#startDate").val();
			var receiveId = $("#receiveId").val();
			var reg=  /^(?:(?!0000)[0-9]{4}(?:(?:0[1-9]|1[0-2])(?:0[1-9]|1[0-9]|2[0-8])|(?:0[13-9]|1[0-2])(?:29|30)|(?:0[13578]|1[02])31)|(?:[0-9]{2}(?:0[48]|[2468][048]|[13579][26])|(?:0[48]|[2468][048]|[13579][26])00)0229)$/; 
			if(!reg.test(startDate)){
				 alert("开始日期格式不正确，正确格式为：yyyymmdd");  
				 return false;
			}
			if(endDate != "长期"&&!reg.test(endDate)){
				alert("结束日期格式不正确，正确格式为：yyyymmdd");  
				return false;
			}
			$.ajax({
				url:"<%=basePath%>operatorAuthCheck/updateIdCardDate.ct",
				type:"post",
				data:{"receiveId":receiveId,"startDate":startDate,"endDate":endDate},
				dataType:"json",
				success:function(result){
					var msgCode = result.msgCode;
					if(msgCode == "0000"){
						alert("修改成功");
					}else{
						alert("修改失败");
					}
					
				},error:function(){
					alert("未知错误！");
				}
			});
		});
      	
    });   
       
    function checkForm(){
    	var val=$('input:radio[name="status"]:checked').val();
    	if(val==null){
            alert("请选择审核操作");
            return false;
        }
    	$("#submitBtn").attr("disabled",true);
    	return true;
    }
        
    function textCounter(field, maxlimit) { 
    	if (field.value.length > maxlimit){ 
    		field.value = field.value.substring(0, maxlimit); 
    	} 
     }
    
    function yzIdCard(){
    	var idCard = $("#idCard").val();
    	var realName = $("#realName").val();
    	$("#yzBtn").attr('disabled',true);
    	$.ajax({
			url:"<%=basePath%>operatorAuthCheck/yzIdCard.ct",
			type:"post",
			data:{"realName":realName,"idCard":idCard},
			dataType:"json",
			success:function(result){
				var msgCode = result.msgCode;
				var msgText = result.msgText;
				if(msgCode == "00"){
					alert("认证一致");
					var photos = result.photos;
					var strShow = "data:image/jpeg;base64,"+photos;
					var str = "<img  src='"+strShow+"' style='width: 200px; hight: 200px'>";
					$("#tdShow").html(str);
					$("#trShow").show();
				}else{
					alert(msgText);
				}
				
			},error:function(){
				alert("未知错误！");
			}
		});
    }
    
     
</script>
</body>
</html>
